<%@ENABLESESSIONSTATE=FALSE LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
	Option Explicit
	
	Dim c_ColPerRow, c_StartCel, c_EndCel, c_nFillCels, c_isRowEnd, c_DataTotal, c_Count, c_arrData
	Dim TDstyle, Image, ImgOrientation, LayoutFormat
						
	dim ar, s, ArticleName, ArticleID, ckid, totalimage, curPg, t, j
	Dim i, aData2, hasData2, nRows2
	dim strURL, SubCat, strAction, txtStyle, ImageW, sAvatarO, sAvatarC

Dim leftmenu
leftmenu = "../../"	
Dim seo_model_img, seo_ads_img, seo_mode_img
seo_model_img = "../../hinh-anh-nguoi-mau"
seo_ads_img = "../../hinh-quang-cao"
seo_mode_img = "../../hinh-thoi-trang"
	
	s = request("list")
	ArticleID = request("aid")
	ArticleName = request("an") & ArticleID
	ckid= request("ckid")
	curPg = request("curPgNum")
	'response.write s & "<br>"
	t = split(s, ",")	

	totalimage = ubound(split(s, ","))
	'response.write "totalimage=" &totalimage
	if instr(s, ",") = 0 then totalimage = totalimage + 1
	LayoutFormat = request("layout")
	SubCat = request("scid")
	redim aData2(5,totalimage)
	for i = 0 to ubound(t)
		dim temp
		temp = split(t(i), ";")
		for j = 0 to ubound(temp)
			aData2(j,i) = temp(j)
		next		
	next
	
	if ubound(aData2, 2) > 0 then
		hasData2  = true
		nRows2 = ubound(aData2, 2)
		if instr(s, ",") = 0 then nRows2 = nRows2 - 1	
	end if
	
	'response.write "nRows2 = " & nRows2
%>
<!--#include file="../admin/includes/func_checkTypeArticle.asp"-->
<!--#include file="../admin/includes/function.asp"-->
				<table cellpadding="0" cellspacing="1" border="0" bgcolor="#B6A8AD"  width="99%" align="center">
				<!--Product Listings-->
					<% 	
					If hasData2 Then 
					
					'Assign variables
					If LayoutFormat = 2 Then 'avatar layout
						c_ColPerRow = 5
					Else
						c_ColPerRow = 2
					End If
					c_DataTotal = nRows2
					c_Count = 0										

					TDstyle = "align=""right"""
					response.write "<tr>"
					For c_Count = 0 To nRows2
						IF aData2(4, c_Count) = 0 then		
							'system--------------------------------
							If ((c_Count + 1) Mod c_ColPerRow)=0 Then
								c_isRowEnd = True
							End If
							'system--------------------------------	
																				
							'Write data Start
							If c_Count <= c_DataTotal Then 'Real Data	
								
								If hasData2 and ArticleName <> "" Then
									Image= ArticleName  & aData2(0,c_Count) & ".jpg"								
								Else 
									Image="de_clear.gif"
								End If						
								strURL="iid=" & aData2(3,c_Count) & "&in="&Image&"&o=v&aid="&ArticleID&"&ckid="&ckid
								
								If iswallpaper(SubCat) = true Then	
									strAction="<a href='" &leftmenu& "download.asp?iid=" & aData2(3,c_Count) & "&is=1024&in=" & Image & "&dt=4' class='DetailAction' >1024x768</a>|<a href='" &leftmenu& "download.asp?iid=" & aData2(3,c_Count) & "&is=800&in=" & Image & "&dt=4' class='DetailAction'>800x600</a>|<a href='" &leftmenu& "emailfriend.asp?dt=4&" & strURL & "' class='DetailAction'>Gửi hình nền</a>"
								ElseIf isavatar(SubCat) = true Then 'avatar
									sAvatarO="<a href='" &leftmenu& "download.asp?iid=" & aData2(3,c_Count) & "&in=" & Image & "&dt=5' class='DetailAction' style='margin:2'>"
									sAvatarC="</a>"
									strAction="<a href='" &leftmenu& "download.asp?iid=" & aData2(3,c_Count) & "&in=" & Image & "&dt=5' class='DetailAction' style='margin:2'>Tải avatar</a>"
								Else
									strAction="<img src='" &seo_mode_img& "/ico_ecard.gif' width='19' height='18' border='0' align='absmiddle'><a href='" &leftmenu& "ecard.asp?dt=3&" & strURL & "' class='DetailAction' style='margin:0 6 0 0'>Gửi thiệp số</a><img src='" &seo_mode_img& "/ico_album.gif' width='19' height='18' border='0' align='absmiddle'><a href='" &leftmenu& "user_favimg_add.asp?aid="&ArticleID&"&fid="&aData2(3,c_Count)&"&dt=3&ckid="&ckid&"' class='DetailAction' style='margin:0px;'>Lưu  album</a><img src='" &seo_mode_img& "/ico_album.gif' width='19' height='18' border='0' align='absmiddle'><a href='" &leftmenu& "review2.asp?image="&seo_model_img&"/"&Image&"&fid="&aData2(3,c_Count)&"' class='DetailAction' target='new' style='margin:0px;'>đánh giá</a>"
								End If	
								
								If LayoutFormat = 2 Then 'avatar layout									
										TDstyle =  "align=""center"""
										txtStyle="margin:1px"									
								Else
									If ((c_Count) Mod c_ColPerRow)=0 Then
										TDstyle =  "align=""left"""
										txtStyle="margin-left:3px"
									Else
										TDstyle = "align=""right"""
										txtStyle="margin-right:3px"
									End If
								End If
								
								If aData2(2,c_Count) <> "" and aData2(2,c_Count) <> "0" Then
									ImageW=aData2(2,c_Count) 
								Else
									ImageW="250"
								End If											
									%>			
									<td valign="top" width="50%" <%= TDstyle %>>
										<div style="width:<%= ImageW %>px; <%=txtStyle%>;"><%=sAvatarO%><img src="<%= seo_model_img%>/<%= Image %>" border="0" alt="<%= aData2(1,c_Count) %>" title="<%= aData2(1,c_Count) %>"><%=sAvatarC%></div>
										<div style="width:<%= ImageW %>px; text-align:left; <%=txtStyle%>; background-color:#7C6787;"><%=strAction%></div>
										<div style="width:<%= ImageW %>px;font-size:10px; text-align:left; <%=txtStyle%>;"><h5 style="margin:5 0 8 0; line-height:130%"><% If aData2(1,c_Count) <> "" Then response.Write(trim(aData2(1,c_Count))) End If %></h5></div>
									</td>								
						<%	Else 'Fill Cells
								response.write "<td " & TDstyle & " width=""50%"">&nbsp;</td>" & vbcrlf	
							End If
							'Write data End							
							'system-------------------------------
							If c_isRowEnd Then							
								response.write "</tr>" & vbcrlf		
								'If c_Count < c_EndCel - 1 Then
									response.write "<tr>" & vbcrlf	
								'End If								
								c_isRowEnd = False
							End If								
							'system-------------------------------										
							
						'horizontal
						else
							Image = ArticleName &  aData2(0,c_Count) & ".jpg"
							strURL="iid=" & aData2(3,c_Count)& "&in="&Image&"&o=h&aid="&ArticleID&"&ckid="&ckid
							
							If SubCat = "35" Then	
								strAction="<a href='" &leftmenu& "download.asp?iid=" & aData2(3,c_Count) & "&is=1024&in=" & Image & "&dt=4' class='DetailAction' >1024x768</a>|<a href='" &leftmenu& "download.asp?iid=" & aData2(3,c_Count) & "&is=800&in=" & Image & "&dt=4' class='DetailAction' >800x600</a>|<a href='" &leftmenu& "emailfriend.asp?dt=4&" & strURL & "' class='DetailAction'>Gửi hình nền</a>"
							ElseIf SubCat = "49" Then 'avatar
								sAvatarO="<a href='" &leftmenu& "download.asp?iid=" & aData2(3,c_Count) & "&in=" & Image & "&dt=5' class='DetailAction' style='margin:2'>"
								sAvatarC="</a>"
								strAction="<a href='" &leftmenu& "download.asp?iid=" & aData2(3,c_Count) & "&in=" & Image & "&dt=5' class='DetailAction' style='margin:2'>Tải avatar</a>"							
							Else
								strAction="<img src='" &seo_mode_img& "/ico_ecard.gif' width='19' height='18' border='0' align='absmiddle'><a href='" &leftmenu& "ecard.asp?dt=3&" & strURL & "' class='DetailAction' style='margin:0 6 0 0'>Gửi thiệp số</a><img src='" &seo_mode_img& "/ico_album.gif' width='19' height='18' border='0' align='absmiddle'><a href='" &leftmenu& "user_favimg_add.asp?aid="&ArticleID&"&fid="&aData2(3,c_Count)&"&dt=3&ckid="&ckid&"' class='DetailAction' style='margin:0px;'>Lưu vào album</a>"
							End If	
							
							If aData2(2,c_Count) <> "" Then
									ImageW=aData2(2,c_Count)
								Else
									ImageW="506"
								End If	
							%>	
							<tr>
								<td colspan="2" align="center">
									<div style="width:<%= ImageW %>px; background-color:#7C6787"><%= sAvatarO %><img src="<%= seo_model_img%>/<%= Image %>" border="0" alt="<%= aData2(1,c_Count) %>" title="<%= aData2(1,c_Count) %>"><%= sAvatarC %></div>
									<div style="width:<%= ImageW %>px; text-align:left;background-color:#7C6787;"><%=strAction%></div>
									<div style="width:<%= ImageW %>px; font-size:10px; text-align:left;"><h5 style="margin:5 0 8 0; line-height:130%"><% If aData2(1,c_Count) <> "" Then response.Write(trim(aData2(1,c_Count))) End If %></h5></div>
								</td>
							</tr>
							<%	
						End if
							Next 
						End If%>
						</table>